package scenetracer.core;

import java.util.ArrayList;

import scenetracer.core.primitive.IntersectionState;
import scenetracer.core.shader.Shader;
import scenetracer.image.Color;
import scenetracer.math.Matrix4;
import scenetracer.math.Point2;
import scenetracer.math.Point3;
import scenetracer.math.Vector3;

public abstract class Primitive {
	
	String name;
	private Color color = Color.RED;
	private ArrayList<Shader> shaders;
	protected Texture texture;
	public float diffuseK;
	public float reflectionK;
	public float refractionK;
	public float refractionIndex;
		
	public Primitive(){
		diffuseK = 0.0f;
		reflectionK = 0.0f;
		setRefractionK(0.0f);
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}	

	public ArrayList<Shader> getShaders() {
		return shaders;
	}

	public void setShaders(ArrayList<Shader> shaders) {
		this.shaders = shaders;
		
		for (Shader shader : shaders) {
			shader.setPrim(this);
		}
	}
	
	public abstract Vector3 getNormal(IntersectionState intersection);

	public abstract Point2 getTextureCoords(Point3 point);
		
	public abstract boolean Intersect(Ray ray, IntersectionState intersection);


	public float getDiffuseK(){
		return diffuseK;
	}
	
	public void setDiffuseK(float value){
		this.diffuseK = value;
	}
	
	public void setReflectionK(float reflectionK) {
		this.reflectionK = reflectionK;
	}

	public float getReflectionK() {
		return reflectionK;
	}
	
	@Override
	public String toString() {	
		return super.toString() + " Name: " + this.name + " Color: " + this.color;
	}

	public void setRefractionK(float refractionK) {
		this.refractionK = refractionK;
	}

	public float getRefractionK() {
		return refractionK;
	}

	public void setRefractionIndex(float refractionIndex) {
		this.refractionIndex = refractionIndex;
	}

	public float getRefractionIndex() {
		return refractionIndex;
	}

	
}
